package cn.tedu.charging.cost.controller;

import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.pojo.param.ChargingProcessParam;
import cn.tedu.charging.common.pojo.vo.ChargingProcessVO;
import cn.tedu.charging.cost.service.CostService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/cost")
@Api(tags = "计价模块")
public class CostController{
    @Autowired
    private CostService costService;

    @PostMapping("/calculate")
    public JsonResult<ChargingProcessVO> calculate
            (@RequestBody ChargingProcessParam param){
        log.debug("计算价格入参:{}",param);
        ChargingProcessVO vo = costService.calculate(param);
        log.debug("计算价格入参:{},出参:{}",param,vo);
        return JsonResult.ok(vo,"计算价格成功");
    }
}
